package com.bruce.apkinstaller.install;

/**
 * Created by Administrator on 2018/1/17.
 * 安装类型工厂
 */

public class FactoryInstallType {

    /**
     * 获取指定类型的对象
     *
     * @param optionBool true:调用系统安装方式
     *                   false:命令行安装方式
     * @return
     */
    public InInstall getInstallType(boolean optionBool) {
        if (getType(optionBool) == null) {
            return null;
        }
        if (getType(optionBool).equalsIgnoreCase(ConstantInstallType.PM_INSTALL)) {
            return new ProductPmInstallImpl();
        }
        if (getType(optionBool).equalsIgnoreCase(ConstantInstallType.ARGS_INSTALL)) {
            return new ProductArgsInstallImpl();
        }
        return null;
    }

    private String getType(boolean tag) {
        if (tag) {
            return ConstantInstallType.PM_INSTALL;
        } else {
            return ConstantInstallType.ARGS_INSTALL;
        }
    }
}
